package cn.qy.kotlin.base

/**
 * 运算符
 */
fun main() {
    fun testRange() {
        for (x in 0..5) {   //定义闭区间包含0和5
            print("$x,")
        }
        println()

        for (x in 0 until 5) {  //定义半开区间包含0，不包含5
            print("$x,")
        }
        println()
        for (x in 'A'..'E') {  //定义闭区间包含'A'和'E'
            print("$x,")
        }
        println()

        for (x in 'A' until 'E') { //定义半开区间包含'A'，不包含'E'
            print("$x,")
        }
        println()
    }
    testRange()

    fun test安全调用运算符() {
        var divNumber1: Int? = null
        var result1 = divNumber1?.plus(1)
        println(result1)

        divNumber1 = 99
        result1 = divNumber1?.plus(1)
        println(result1)
    }
    test安全调用运算符()
}
